import { ObjCreate } from "../common/ObjCreate";
import { TitleItem } from "../common/item/TitleItem";
import { Language } from "../../../../extend/language/Language";
import { ObjTeamCreate } from "../common/ObjTeamCreate";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { TilePanel } from "../equipment/TilePanel";
import { GangFightsApplyTeamCellRenderer } from "./cellRenderer/GangFightsApplyTeamCellRenderer";
import { PageSelecter } from "../common/pageSelect/PageSelecter";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { GangFightsGetTopListdata } from "./data/GangFightsGetTopListdata";
import { EGangFightsOrderObjType } from "../../../../Message/Public/EGangFightsOrderObjType";
import { SGangFightsToplist } from "../../../../Message/Public/SGangFightsToplist";
import { DataProvider } from "../../../../fl/data/DataProvider";
import { GCheckBox } from "../../../../com/mui/controls/GCheckBox";
import { GButton } from "../../../../com/mui/controls/GButton";
type int = number;
//class GangFightsApplyTeamListPanel
    
    export  class GangFightsApplyTeamListPanel /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.init();
            this.addEventListener(flash.events.Event.ADDED_TO_STAGE, this.onAddToStage);
            return;
        }

        public onAddToStage(arg1: Object /* flash.events.Event */): void
        {
            this.getList();
            return;
        }

        /* internal  */init(): void
        {
            ObjCreate.createSpBannerAndBg(0, 0, 802, 450, "", this);
            var loc1=new Vector.<TitleItem>();
            loc1.push(new TitleItem(Language.getString(44441), 60));
            loc1.push(new TitleItem(Language.getString(44442), 180));
            loc1.push(new TitleItem(Language.getString(44443), 180));
            loc1.push(new TitleItem(Language.getString(44444), 60));
            loc1.push(new TitleItem(Language.getString(44445), 80));
            loc1.push(new TitleItem(Language.getString(44446), 80));
            loc1.push(new TitleItem(Language.getString(44447), 160));
            var loc2=ObjTeamCreate.createTitles(loc1);
            ObjCreate.setObjAttri(loc2, 2, 8, -1, -1, this);
            this._tfNoResult = ObjCreate.createTextField(Language.getString(44448), 374, 210, 200, 20, this, GlobalStyle.textFormat6);
            this._applyTeamListPanel = new TilePanel();
            this._applyTeamListPanel.setSize(802, 420);
            this._applyTeamListPanel.rowHeight = 42;
            this._applyTeamListPanel.columnWidth = 802;
            this._applyTeamListPanel.setStyle("cellRenderer", GangFightsApplyTeamCellRenderer);
            this._applyTeamListPanel.x = 5;
            this._applyTeamListPanel.y = 30;
            this._applyTeamListPanel.visible = false;
            this.addChild(this._applyTeamListPanel);
            this._pageSelecter = new PageSelecter();
            this._pageSelecter.mode = PageSelecter.InputMode;
            this._pageSelecter.x = 272;
            this._pageSelecter.y = 458;
            this._pageSelecter.pageTextBoxSize = 50;
            this.addChild(this._pageSelecter);
            this._pageSelecter.addEventListener(flash.events.Event.CHANGE, this.onChange);
            this._btnCreateTeam = ObjCreate.createGButton(Language.getString(44450), 700, 454, 70, 26, this, "ButtonRed");
            this._btnCreateTeam.addEventListener(flash.events.MouseEvent.CLICK, this.onClickCreateTeam);
            return;
        }

        /* internal  */onCheckBoxChange(arg1: Object /* flash.events.Event */): void
        {
            this.getList();
            return;
        }

        /* internal  */onBtnRefreshClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            this.getList();
            return;
        }

        /* internal  */onClickCreateTeam(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.GangFightsShowCreateTeamWindow));
            return;
        }

        /* internal  */onChange(arg1: Object /* flash.events.Event */): void
        {
            this.getList();
            return;
        }

        /* internal  */getList(): void
        {
            this._isRequestData = true;
            var loc1=new GangFightsGetTopListdata();
            loc1.page = this._pageSelecter.currentPage;
            loc1.pageSize = this.pageSize;
            loc1.orderObjType = EGangFightsOrderObjType._EGangFightsOrderObjCanApply;
            loc1.onlyMyServer = true;
            Dispatcher.dispatchEvent(new DataEvent(EventName.GangFightsGetTopList, loc1));
            return;
        }

        public updateGangFightsTopList(arg1: SGangFightsToplist): void
        {
            if (arg1.orderObjType == EGangFightsOrderObjType._EGangFightsOrderObjCanApply && this._isRequestData) 
            {
                this._topList = arg1;
                this._pageSelecter.maxPage = arg1.pageNum;
                this._pageSelecter.currentPage = arg1.page;
                this.updateList();
                this.updateVisible();
                this._isRequestData = false;
            }
            return;
        }

        /* internal  */updateList(): void
        {
            this._applyTeamListPanel.dataProvider = new DataProvider(this._topList.teams);
            this._applyTeamListPanel.drawNow();
            return;
        }

        /* internal  */updateVisible(): void
        {
            var loc1=this._topList && this._topList.teams.length > 0;
            this._applyTeamListPanel.visible = loc1;
            this._tfNoResult.visible = !loc1;
            return;
        }

        /* internal */ /* const */pageSize: int=10;

        /* internal */ /* var */_tfNoResult: Object /* flash.text.TextField */;

        /* internal */ /* var */_applyTeamListPanel: TilePanel;

        /* internal */ /* var */_pageSelecter: PageSelecter;

        /* internal */ /* var */_cbShowNotFullOnly: GCheckBox;

        /* internal */ /* var */_btnCreateTeam: GButton;

        /* internal */ /* var */_topList: SGangFightsToplist;

        /* internal */ /* var */_isRequestData: Boolean=false;
    }
